﻿using System.Collections.Concurrent;
using System.Collections.Generic;

namespace OnWork.DataCenter.Utils.Caches
{
    /// <summary>
    /// 变量缓存
    /// 2023年3月30日 14:52:23
    /// </summary>
    public class VariablesCache
    {
        /// <summary>
        /// 静态字典
        /// </summary>
        private static ConcurrentDictionary<string, string> _Dict = new ConcurrentDictionary<string, string>();

        /// <summary>
        /// 设置键值
        /// </summary>
        /// <param name="key"></param>
        /// <param name="val"></param>
        /// <returns></returns>
        public static bool Set(string key, string val)
        {
            _Dict[key] = val;
            return true;
        }


        /// <summary>
        /// 设置键值
        /// </summary>
        /// <param name="key"></param>
        /// <param name="val"></param>
        /// <returns></returns>
        public static bool Remove(string key)
        {
            _Dict.Remove(key,out string val);
            return true;
        }

        /// <summary>
        /// 返回字典
        /// </summary>
        /// <returns></returns>
        public static ConcurrentDictionary<string, string> GETDict()
        {
            return _Dict;
        }
    }
}